#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QDoubleSpinBox>
#include <QMainWindow>
#include <QPushButton>
#include <QLCDNumber>
#include "drawwidget.h"
#include <QComboBox>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

public:
    double chipWidth;   //芯片宽度
    double chipHeight;  //芯片高度
    double hSpace;      //水平间距
    double vSpace;      //垂直间距
    double waferDim;    //晶圆直径
    double edgeSpace;   //边界距离
    double flatHeight;  //平边高度
    double waferPrice;
    double yield;
    double chipPrice;

private:
    Ui::MainWindow *ui;
    QDoubleSpinBox *chipWidthSpinBox;
    QDoubleSpinBox *chipHeightSpinBox;
    QDoubleSpinBox *hSpaceSpinBox;
    QDoubleSpinBox *vSpaceSpinBox;
    QComboBox *waferDimComboBox;
    QDoubleSpinBox *edgeSpaceSpinBox;
    QDoubleSpinBox *flatHeightSpinBox;
    QDoubleSpinBox *waferPriceBox;
    QDoubleSpinBox *yieldBox;
    QLCDNumber *resultView;
    QLCDNumber *chipPriceView;
    QPushButton *computeBtn;
    DrawWidget *drawWidget;
    QPushButton *saveImageBtn;
    QString version;


private slots:
    void on_drawButton_clicked();
    void on_saveImageBtn_clincked();

protected:
    void paintEvent(QPaintEvent *event) override;
    void compute();
    double twoPointDistance(double p1X, double p1Y, double p2X, double p2Y);
    double chipNearestBorderPoint(double centerX, double centerY, double chipCenterX, double chipCenterY, double cw, double ch);
    double FMod(double a, double b);
};
#endif // MAINWINDOW_H
